﻿<ResourceDictionary 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:v="clr-namespace:ShredTheLog.Views;assembly=ShredTheLog.Views"
    xmlns:vm="clr-namespace:ShredTheLog.ViewModels;assembly=ShredTheLog.ViewModels"
    xmlns:cnv="clr-namespace:ShredTheLog.Converters;assembly=ShredTheLog.Converters"
    xmlns:c="clr-namespace:ShredTheLog.Controls;assembly=ShredTheLog.Controls"
    xmlns:tk="clr-namespace:Microsoft.Windows.Controls;assembly=WPFToolkit"
    >

    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="FlashMisc2.xaml"/>
    </ResourceDictionary.MergedDictionaries>

    <DataTemplate DataType="{x:Type vm:UserSearchViewModel}">
        <Grid MaxWidth="880" Margin="0, 5, 0, 5">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="8"/>
                <ColumnDefinition Width="Auto"/>
            </Grid.ColumnDefinitions>

            <Border Grid.Column="0" Padding="8, 0, 8, 8" Style="{StaticResource ShadowedBorderStyle}">
                <Grid HorizontalAlignment="Center" VerticalAlignment="Stretch">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="*"/>
                        <RowDefinition Height="10"/>
                        <RowDefinition Height="220"/>
                    </Grid.RowDefinitions>

                    <TextBlock Grid.Row="0" Style="{StaticResource HeaderStyle}" HorizontalAlignment="Stretch"  Margin="0, 2, 0, 2" TextWrapping="Wrap" TextAlignment="Center">
                        <TextBlock.Text>
                            <MultiBinding StringFormat="{c:LocalizedString s_MembersFound}">
                                <Binding Path="TotalUserCount"/>
                                <Binding Path="PageIndex" Converter="{x:Static cnv:IncrementingConverter.Default}"/>
                                <Binding Path="PageCount"/>
                            </MultiBinding>
                        </TextBlock.Text>
                    </TextBlock>
                    
                    <tk:DataGrid Grid.Row="1" ItemsSource="{Binding Users}" CanUserSortColumns="False">
                        <ItemsControl.ItemContainerStyle>
                            <Style TargetType="{x:Type tk:DataGridRow}">
                                <Setter Property="ContextMenu">
                                    <Setter.Value>
                                        <ContextMenu c:Extensions.Items="{Binding Converter={x:Static vm:UserMenuItemsConverter.Default}}" DataContext="{Binding RelativeSource={RelativeSource Mode=Self}, Path=PlacementTarget.DataContext}"/>
                                    </Setter.Value>
                                </Setter>
                            </Style>
                        </ItemsControl.ItemContainerStyle>
                        <tk:DataGrid.Columns>
                            <tk:DataGridTemplateColumn Header="{x:Null}" CanUserResize="False">
                                <tk:DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                        <ContentPresenter Content="{Binding Gender}" HorizontalAlignment="Center"/>
                                    </DataTemplate>
                                </tk:DataGridTemplateColumn.CellTemplate>
                            </tk:DataGridTemplateColumn>
                            <tk:DataGridTextColumn Header="{c:LocalizedString s_Name}" Binding="{Binding Name}" Width="*"/>
                            <tk:DataGridTextColumn Header="{c:LocalizedString s_NativeLanguages}" Binding="{Binding Path=KnownLanguages, Converter={x:Static cnv:LanguagesConverter.Default}}" Width="2*"/>
                            <tk:DataGridTextColumn Header="{c:LocalizedString s_PracticingLanguages}" Binding="{Binding Path=PracticingLanguages, Converter={x:Static cnv:LanguagesConverter.Default}}" Width="2*"/>
                            <tk:DataGridTextColumn Header="{c:LocalizedString s_Country}" Binding="{Binding Path=Country, Converter={x:Static cnv:CountryConverter.Default}}" Width="*"/>
                            <tk:DataGridTextColumn Header="{c:LocalizedString s_Age}" Binding="{Binding Age}">
                                <tk:DataGridTextColumn.ElementStyle>
                                    <Style TargetType="{x:Type TextBlock}">
                                        <Setter Property="TextAlignment" Value="Right"/>
                                    </Style>
                                </tk:DataGridTextColumn.ElementStyle>
                            </tk:DataGridTextColumn>
                        </tk:DataGrid.Columns>
                    </tk:DataGrid>

                    <ProgressBar Grid.Row="1" Width="32" Height="32" HorizontalAlignment="Center" VerticalAlignment="Center" IsIndeterminate="True" Visibility="{Binding Path=IsLoading, Converter={StaticResource BoolToVisibilityConverter}}"/>

                    <GridSplitter Grid.Row="2" VerticalAlignment="Center" HorizontalAlignment="Stretch" Focusable="False" Height="3"/>
                    <Border Grid.Row="3" BorderThickness="1" BorderBrush="#7480A4" Padding="4" Background="{StaticResource LightGrayBackgroundBrush}" Effect="{StaticResource SmallShadow}">
                        <ContentPresenter Content="{Binding Users/, Converter={x:Static vm:UserProfileConverter.Default}}"/>
                    </Border>
                </Grid>
            </Border>

            <Border Grid.Column="2" Background="{StaticResource GrayBackgroundBrush}" Padding="0, 5, 0, 5" VerticalAlignment="Top" Style="{StaticResource ShadowedBorderStyle}">
                <StackPanel Orientation="Vertical">
                    <Button Content="{c:LocalizedString s_NextPage}" Command="{Binding NextPageCommand}" Style="{StaticResource SideMenuButtonStyle}"/>
                    <Button Content="{c:LocalizedString s_PreviousPage}" Command="{Binding PreviousPageCommand}" Style="{StaticResource SideMenuButtonStyle}"/>
                    <Button Content="{c:LocalizedString s_NewSearch}" Command="{Binding ShowConditionsCommand}" Style="{StaticResource SideMenuButtonStyle}"/>
                </StackPanel>
            </Border>
        </Grid>
    </DataTemplate>
</ResourceDictionary>